//
//  HttpRequestManager.h
//  AFNetworkingDemo
//
//  Created by MLS on 16/7/8.
//  Copyright © 2016年 MLS. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AFNetworking.h>

@class UploadParam;

/**
 *  网络请求类型
 */
typedef NS_ENUM(NSInteger, HttpRequestType) {
    /**
     *  Get
     */
    HttpRequestTypeGet = 0,
    /**
     *  Post
     */
    HttpRequestTypePost
};

@interface HttpRequestManager : NSObject

+( HttpRequestManager *_Nonnull)sharedManager;

/**
 *  发送get请求
 *
 *  @param URLString  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 */
- (void)getWithURLString:(NSString *_Nonnull)URLString
              parameters:(id _Nullable)parameters
                 success:(void (^ _Nullable)(id _Nullable responseObject))success
                 failure:(void (^ _Nullable)(NSError *_Nonnull error))failure;

/**
 *  发送post请求
 *
 *  @param URLString  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 */
- (void)postWithURLString:(NSString *_Nonnull)URLString
               parameters:(id _Nonnull)parameters
                  success:(void (^ _Nullable)(id _Nullable responseObject))success
                  failure:(void (^ _Nullable)(NSError *_Nonnull error))failure;

/**
 *  发送网络请求
 *
 *  @param URLString   请求的网址字符串
 *  @param parameters  请求的参数
 *  @param type        请求的类型
 *  @param resultBlock 请求的结果
 */
- (void)requestWithURLString:(NSString *_Nonnull)URLString
                  parameters:(id _Nullable)parameters
                        type:(HttpRequestType)type
                     success:(void (^ _Nullable)(id _Nullable responseObject))success
                     failure:(void (^ _Nullable)(NSError *_Nonnull error))failure;

/**
 *  上传图片
 *
 *  @param URLString      地址
 *  @param parameters     参数
 *  @param uploadParamter 上传图片的一些参数
 *  @param success        上传成功回调
 *  @param failure        上传失败会掉
 */
- (void)uploadWithURLString:(NSString *_Nonnull)URLString
                 parameters:(id _Nonnull)parameters
                uploadParam:(UploadParam *_Nonnull)uploadParamter
                    success:(void (^ _Nullable)(id _Nullable responseObject))success
                    failure:(void (^ _Nullable)(NSError *_Nonnull error))failure;

/**
 *  取消请求当前所有网络请求
 */
- (void)cancelAllOperations;

@end
